home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 31 April 1997
- // Author: cdt
- //
- // Description:
- // This implements the user interface for camera bookmarks.
- //
-
- proc buildBookmarkList(string $camera)
- {
- int $selected[] = `textScrollList -q -selectIndexedItem list`;
-
- textScrollList -e -removeAll list;
-
- string $bookmarks[] = `listConnections ($camera+".bookmarks")`;
-
- for ( $item in $bookmarks)
- textScrollList -e -append $item list;
-
- // Was something selected and are there remaining bookmarks ?
- if (size($selected) > 0 && size($bookmarks) > 0) {
- int $index = min($selected[0], size($bookmarks));
- textScrollList -e -selectIndexedItem $index list;
- }
- }
-
- proc string selectedBookmark()
- {
- string $items[] = `textScrollList -q -selectItem list`;
- return (size($items) > 0) ? $items[0] : "";
- }
-
- //
- // Procedure Name:
- // cameraBookmarkListCB
- //
- // Description:
- // This procedure is called when the user selects an item in the
- // list. The name and description controls are updated to reflect
- // this item.
- //
- global proc cameraBookmarkListCB(string $parent)
- {
- setParent $parent;
-
- string $item = selectedBookmark();
-
- if ($item != "") {
- textFieldGrp -e -text $item name;
- textFieldGrp -e -text `getAttr ($item+".description")` desc;
- }
- else {
- textFieldGrp -e -text "" name;
- textFieldGrp -e -text "" desc;
- }
- }
-
- //
- // Procedure Name:
- // cameraBookmarkNameCB
- //
- // Description:
- // This procedure is called when the user has modified the
- // text of the name control.
- //
- global proc cameraBookmarkNameCB(string $parent, string $camera)
- {
- setParent $parent;
-
- string $item = selectedBookmark();
-
- // Nothing is selected ?
- if ($item == "") {
- // Create a new item and assign the name.
-
- $item = `cameraView -addBookmark -camera $camera`;
- string $name = `textFieldGrp -q -text name`;
- string $newName = `rename $item $name`;
- buildBookmarkList($camera);
- textScrollList -e -selectItem $newName list;
- textFieldGrp -e -text $newName name;
- textFieldGrp -e -text "" desc;
- }
- else {
- // Modify name of the selected item.
-
- string $name = `textFieldGrp -q -text name`;
- string $newName = `rename $item $name`;
- buildBookmarkList($camera);
- textFieldGrp -e -text $name name;
- }
- }
-
- //
- // Procedure Name:
- // cameraBookmarkNameCB
- //
- // Description:
- // This procedure is called when the user has modified the
- // text of the description control.
- //
- global proc cameraBookmarkDescCB(string $parent, string $camera)
- {
- setParent $parent;
-
- string $item = selectedBookmark();
-
- // Nothing is selected ?
- if ($item == "") {
- // Create a new item and assign the description.
-
- $item = `cameraView -addBookmark -camera $camera`;
- string $description = `textFieldGrp -q -text desc`;
- setAttr ($item+".description") -type "string" $description;
- buildBookmarkList($camera);
- textScrollList -e -selectItem $item list;
- textFieldGrp -e -text $item name;
- }
- else {
- // Modify description of the selected item.
-
- string $desc = `textFieldGrp -q -text desc`;
- setAttr ($item+".description") -type "string" $desc;
- }
- }
-
- //
- // Procedure Name:
- // cameraBookmarkApplyCB
- //
- // Description:
- // This procedure is called when the user has pressed the apply
- // button or double clicked on an item in the list. The selected
- // view is applied to the camera.
- //
- global proc cameraBookmarkApplyCB(string $parent, string $camera)
- {
- setParent $parent;
-
- string $item = selectedBookmark();
-
- if ($item != "") {
- cameraView -e -camera $camera -setCamera $item;
- }
- }
-
- //
- // Procedure Name:
- // cameraBookmarkShelfCB
- //
- // Description:
- // This procedure is called when the user has pressed the shelf
- // button.
- //
- global proc cameraBookmarkShelfCB(string $parent, string $camera)
- {
- setParent $parent;
-
- string $item = selectedBookmark();
-
- if ($item != "") {
- global string $gShelfTopLevel;
-
- if (`tabLayout -exists $gShelfTopLevel`) {
- string $currentShelf = `tabLayout -q -selectTab $gShelfTopLevel`;
-
- string $cmdStr =
- "cameraView -e -camera "+$camera+" -setCamera "+$item;
-
- shelfButton
- -p ($gShelfTopLevel + "|" + $currentShelf)
- -image1 "commandButton.xpm"
- -label $item
- -style `shelfLayout -q -style $currentShelf`
- -width `shelfLayout -q -cellWidth $currentShelf`
- -height `shelfLayout -q -cellHeight $currentShelf`
- -c $cmdStr;
- }
- }
- }
-
- //
- // Procedure Name:
- // cameraBookmarkNewCB
- //
- // Description:
- // This procedure is called when the user has pressed the new
- // button. A new camera view using the current camera position is
- // created.
- //
- global proc cameraBookmarkNewCB(string $parent, string $camera)
- {
- setParent $parent;
-
- string $item = `cameraView -addBookmark -camera $camera`;
- buildBookmarkList($camera);
- textScrollList -e -selectItem $item list;
- textFieldGrp -e -text $item name;
- textFieldGrp -e -text "" desc;
- }
-
- //
- // Procedure Name:
- // cameraBookmarkDelCB
- //
- // Description:
- // This procedure is called when the user has pressed the delete
- // button or pressed the delete key. The selected view is deleted.
- //
- global proc cameraBookmarkDelCB(string $parent, string $camera)
- {
- setParent $parent;
-
- string $item = selectedBookmark();
-
- if ($item != "") {
- delete $item;
- buildBookmarkList($camera);
- cameraBookmarkListCB($parent);
- }
- }
-
- //
- // Procedure Name:
- // cameraBookmarkEditor
- //
- // Description:
- // Display an editor for editting the bookmarks associated with
- // camera.
- //
- global proc cameraBookmarkEditor( string $camera )
- {
- string $title = "Bookmark Editor (" + $camera + ")";
-
- string $win = `window -title $title -iconName "Bookmarks" cameraBookmarkWindow`;
- formLayout winForm;
- textScrollList -height 180 list;
-
- columnLayout -adj true col;
- textFieldGrp -l "Name" name;
- textFieldGrp -l "Description" desc;
- separator -style none -height 15;
-
- formLayout btnForm;
- button -l "Apply" apply;
- button -l "Add To Shelf" shelf;
- button -l "New Bookmark" new;
- button -l "Delete" del;
- setParent ..;
-
- button -l "Close" close;
-
-
- formLayout -e
- -af apply left 20
- -af apply top 0
- -ap apply right 5 25
- -af apply bottom 10
-
- -af shelf top 0
- -ap shelf left 5 25
- -ap shelf right 5 50
- -af shelf bottom 10
-
- -af new top 0
- -ap new left 5 50
- -ap new right 5 75
- -af new bottom 10
-
- -af del right 20
- -af del top 0
- -ap del left 5 75
- -af del bottom 10
-
- btnForm;
-
- formLayout -e
- -af list left 15
- -af list top 10
- -af list right 15
- -ac list bottom 10 col
-
- -af col left 10
- -af col bottom 10
- -af col right 10
-
- winForm;
-
- buildBookmarkList($camera);
-
- textScrollList -e -sc ("cameraBookmarkListCB "+$win) list;
- textScrollList -e -dcc ("cameraBookmarkApplyCB "+$win+" "+$camera) list;
- textScrollList -e -dkc ("cameraBookmarkDelCB "+$win+" "+$camera) list;
- textFieldGrp -e -cc ("cameraBookmarkNameCB "+$win+" "+$camera) name;
- textFieldGrp -e -cc ("cameraBookmarkDescCB "+$win+" "+$camera) desc;
- button -e -c ("cameraBookmarkApplyCB "+$win+" "+$camera) apply;
- button -e -c ("cameraBookmarkShelfCB "+$win+" "+$camera) shelf;
- button -e -c ("cameraBookmarkNewCB "+$win+" "+$camera) new;
- button -e -c ("cameraBookmarkDelCB "+$win+" "+$camera) del;
- button -e -c ("deleteUI "+$win) close;
-
- showWindow $win;
- }
-
- //
- // Procedure Name:
- // buildCameraBookmarkMenu
- //
- // Description:
- // Create a menu item for each the bookmark views associated with
- // the current camera. New bookmarks can be created with or
- // without a description.
- //
- global proc buildCameraBookmarkMenu( string $parent, string $panel )
- {
- setParent -m $parent;
-
- menu -e -deleteAllItems $parent;
-
- string $camera = `modelPanel -q -camera $panel`;
-
- // Create a menu item for each bookmark
-
- string $bookmarks[] = `listConnections ($camera+".bookmarks")`;
-
- for ( $item in $bookmarks) {
- menuItem -l $item
- -c ("cameraView -e -camera "+$camera+" -setCamera "+$item);
- }
-
- menuItem -divider true;
-
- menuItem -l "Edit Bookmarks..." -c ("cameraBookmarkEditor "+$camera);
- }
-